﻿@using Smartstore.Web.Models.Catalog

@model IList<ProductSpecificationModel>

@{
    if (Model.Count == 0)
    {
        return;
    }

    var grouped = Model.GroupBy(x => x.SpecificationAttributeName);
}

<div class="pd-specs table-responsive">
    <table class="table pd-specs-table">
        <tbody>
            @foreach (var group in grouped)
            {
                <tr>
                    <td class="pd-spec-name" sm-language-attributes-for="group.Key">@group.Key</td>
                    <td class="pd-spec-value">
                        @if (group.Count() == 1)
                        {
                            var option = group.First().SpecificationAttributeOption;
                            <span sm-language-attributes-for="option">@option</span>
                        }
                        else if (group.Count() > 1)
                        {
                            <ul class="mb-0 pl-3">
                                @foreach (var item in group)
                                {
                                    <li class="pb-1"><span sm-language-attributes-for="item.SpecificationAttributeOption">@item.SpecificationAttributeOption</span></li>
                                }
                            </ul>
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>